/********************************************
 * my_cmd.c
 * 传入命令行字符串ss，传入传出命令cmd以及参数arg
 * 返回命令的类型
 *
 ********************************************/

#include "../include/head.h"

int CMDtype(const char *ss, char *cmd, char *arg){
    int cmdType = 0;
    //把命令和参数进行分离
    sscanf(ss, "%s ", cmd);
    sscanf(ss, "%*s %s", arg);

    if(!strcmp(cmd, "cd")){
        cmdType = 1;
    }
    else if(!strcmp(cmd, "ls")){
        cmdType = 2;
    }
    else if(!strcmp(cmd, "pwd")){
        cmdType = 3;
    }
    else if(!strcmp(cmd, "upload")){
        cmdType = 4;
    }
    else if(!strcmp(cmd, "download")){
        cmdType = 5;
    }
    else if(!strcmp(cmd, "rm")){
        cmdType = 6;
    }
    else if(!strcmp(cmd, "mkdir")){
        cmdType = 7;
    }
    else{
        cmdType = 0;
    }

    return cmdType;
}

